package com.bytedance.common.plugin.mop;

import com.bytedance.common.plugin.framework.util.b;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.reflect.Reflect;

import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap;

public class MopAgentUtil {
    private static b<Class<?>, String, MopAgent> sRunAsLocalMap = new b();

    public MopAgentUtil() {

    }

    public static MopAgent getMopAgentAnnotation(Class clazz, String method, Class[] arg6, Object[] arg7) {
        MopAgent v0_3;
        MopAgent v1 = null;
        b v0 = MopAgentUtil.sRunAsLocalMap;
        boolean v0_1 = v0.a.containsKey(clazz) ? ((ConcurrentHashMap) v0.a.get(clazz)).containsKey(method) : false;
        if (v0_1) {
            ConcurrentHashMap<String, MopAgent> map = MopAgentUtil.sRunAsLocalMap.a.get(clazz);
            if (map == null) {
                return null;
            }
            return map.get(method);
        }

        try {
            Method v0_5 = Reflect.onClass(clazz).exactMethod(method, arg6);
            if (v0_5 == null) {
                return v1;
            }
            return v0_5.getAnnotation(MopAgent.class);
        } catch (NoSuchMethodException v0_4) {
            Logger.w("Plugin", "find method = " + method + " from class = " + clazz.getName() + " error");
        }

        return v1;
    }
}

